<template>
    <div class="infobox">
        <div class="itembox">
            <h4>生命体征</h4>
            <el-table :data="tableData"  border style="width: 100%;">
                <el-table-column prop="date" label="身高" width="80"  align="center"/>
                <el-table-column prop="name" label="体重" width="80" align="center" />
                <el-table-column prop="address" label="IBW" width="80"  align="center"/>
                <el-table-column prop="date" label="BMI" width="100" align="center" />
                <el-table-column prop="name" label="腰围" width="80" align="center" />
                <el-table-column prop="address" label="臀围" width="80"  align="center"/>
                <el-table-column prop="date" label="腰臀比" width="80"  align="center"/>
                <el-table-column prop="name" label="收缩压（高）"align="center" />
                <el-table-column prop="address" label="舒张压（低）" align="center"/>
                <el-table-column prop="date" label="状态" width="80" align="center"/>
                <el-table-column prop="name" label="静息心率" width="80"align="center" />
                <el-table-column prop="address" label="检查日期" width="100" align="center"/>
                <el-table-column prop="address" label="操作" center width="150" align="center">
                    <template #default="scope">
                        <div class="czbox">
                            <el-button size="small" @click="handleAdd()">
                                添加记录
                            </el-button>
                            <el-button size="small" @click="handleEdit()">
                                修改
                            </el-button>
                        </div>
                    </template> </el-table-column>
            </el-table>
        </div>

        <el-dialog v-model="dialogVisible" title="新增患者" width="600" :before-close="handleClose">
            <el-form :model="form" label-width="auto" ref="ruleFormRef">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="身高" prop="sg">
                            <div class="addbox">
                                <el-input v-model="form.sg" style="width: 80px;" />
                                <div class="dwbox">cm</div>
                            </div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="体重" prop="tz">
                            <div class="addbox">
                                <el-input v-model="form.tz" style="width: 80px;" />
                                <div class="dwbox">kg</div>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="腰围" prop="yw">
                            <div class="addbox">
                                <el-input v-model="form.yw" style="width: 80px;" />
                                <div class="dwbox">cm</div>
                            </div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="臀围" prop="tw">
                            <div class="addbox">
                                <el-input v-model="form.tw" style="width: 80px;" />
                                <div class="dwbox">cm</div>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="高压" prop="gy">
                            <div class="addbox">
                                <el-input v-model="form.gy" style="width: 80px;" />
                                <div class="dwbox">mmHg</div>
                            </div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="低压" prop="dy">
                            <div class="addbox">
                                <el-input v-model="form.dy" style="width: 80px;" />
                                <div class="dwbox">mmHg</div>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="静息心率" prop="xl">
                            <div class="addbox">
                                <el-input v-model="form.xl" style="width: 80px;" />
                                <div class="dwbox">次/分钟</div>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div v-if="showtable">
                <span>上次数据</span>
                <el-table :data="tableDatatc" style="width: 100%">
                    <el-table-column prop="date" label="身高" />
                    <el-table-column prop="name" label="体重" />
                    <el-table-column prop="address" label="腰围" />
                    <el-table-column prop="date" label="臀围" />
                    <el-table-column prop="name" label="高压" />
                    <el-table-column prop="address" label="低压" />
                    <el-table-column prop="address" label="静息心率" />
                </el-table>
            </div>
            <template #footer>
                <div class="dialog-footer savebox">
                    <el-button @click="resetForm(ruleFormRef)">取消</el-button>
                    <el-button type="primary" @click="savebutton">
                        确定
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup>
import { ref } from 'vue'
let dialogVisible = ref(false)
const ruleFormRef = ref(null)
let showtable=ref(false)
const tableDatatc = [
    {
        date: '10',
        name: '20',
        address: '30',
    },
]
const form = reactive({
})
const tableData = ref([
    {
        date: '10',
        name: '10',
        address: '10',
    }
])
//添加
let handleAdd = () => {
    showtable.value=true
    dialogVisible.value = true
}
//修改
let handleEdit = () => {
    showtable.value=false
    dialogVisible.value = true
   
}
let addbutton = () => {
    dialogVisible.value = true
}
const handleClose = () => {
    dialogVisible.value = false
}
let resetForm = (formEl) => {
    if (!formEl) return
    formEl.resetFields()
    dialogVisible.value = false
}
let savebutton = () => {
    console.log('============>', form)
}
</script>
<style lang='scss' scoped>
.tjjlbox {
    margin-right: 5px;
}

.itembox {
    width: 100%;
    overflow: auto;
}

.czbox {
    display: flex;
    justify-content: space-around;
}

.addbox {
    display: flex;
    justify-content: space-around;
}

.dwbox {
    margin-left: 10px;
}
</style>